let app = getApp()
Component({
    properties: {
      tags:String,
      popup:{
        type: Object,
        observer: function(newVal, oldVal) {
          this.updatepopup()
        }
      },
      params:{
        type: Array,
        observer: function(newVal, oldVal) {
          this.update()
        }
      }
      },
      data:{
        loginShow:false,
        tags:''
      },
    lifetimes: {
        attached: function () {
            
         }
      },
    methods: {
      titchange:function(e){
         if(typeof(e.detail.value)!='undefined'&&e.detail.value.length!='')
         {
           this.setData({
               tags:e.detail.value
            })
         }
      },
      confirm:function(){
        if(typeof(this.data.tags)!='undefined'&&this.data.tags!='')
        {
          if(this.data.popup.btn[1]=='删除'){
            var tags=[]
            tags['old_tag']=this.data.old_tag
            var popup={
              tit: "请输入标签不超过10个字",
              btn: [ "取消", "确认" ],
              flag: !1,
              x: !1
          }
            this.setData({
              popup:popup
            })
            this.triggerEvent('getdelTag',tags)
          }else{
            this.triggerEvent('getPopupData',this.data.tags)
            this.cancel()
          }
        }else{
          wx.showToast({
            title: '请输入标签！',
            icon: 'none',
            duration: 1500
          })
        }
      },
      cancel:function(){
        if(this.data.popup.edit==1){
          if(typeof(this.data.tags)!='undefined'&&this.data.tags!='')
          {
            var tags=[]
            tags['old_tag']=this.data.old_tag,
            tags['new_tag']=this.data.tags
            this.triggerEvent('getPopupData2',tags)
            var popup={
              tit: "请输入标签不超过10个字",
              btn: [ "取消", "确认" ],
              flag: !1,
              x: !1
          }
            this.setData({
              popup:popup
            })
          }else{
            wx.showToast({
              title: '请输入标签！',
              icon: 'none',
              duration: 1500
            })
          }
        }else{
          var popup={
            tit: "请输入标签不超过10个字",
            btn: [ "取消", "确认" ],
            flag: !1,
            x: !1
        }
        this.setData({
          popup:popup
        })
        }
       
      },
      updatepopup:function(){
          var that=this
          if(this.data.popup.edit==1){
            this.setData({
              tags:that.data.popup.label,
              old_tag:that.data.popup.label
            })
          }else{
            this.setData({
              tags:'',
              old_tag:''
            })
          }
      },
      update:function(){
      }
    }
});
